<?php
/**
 * Created by PhpStorm.
 * User: zmit
 * Date: 8/9/17
 * Time: 2:23 PM
 */
namespace AdminBundle\Controller;


class ProjectController extends AdminController
{
    /*
     * 项目列表
     */
    public function projectListAction()
    {
        if(!$this->get("session")->get("admin_id")){

            return $this->render('AdminBundle:Auth:login.html.twig');
        }

        $now_date = date("Y.m.d");
        return $this->render("AdminBundle:Project:index.html.twig",array("date"=>$now_date));
    }

    /*
     * 编辑项目
     */
    public function editProjectAction($id)
    {
        if(!$this->get("session")->get("admin_id")){

            return $this->render('AdminBundle:Auth:login.html.twig');
        }
        if(!empty($id)){
            $data = $this->getApiData("ApiBundle:Admin/Project:detailProject",array("id"=>$id));
        } else {
            $data = array("data"=>array("id" => $id));
        }

        $data['curr_date'] = date("Y-m-d");


        return $this->render("AdminBundle:Project:editProject.html.twig",array("data"=>$data));
    }


    /*
     * 项目详情
     */
    public function projectDetailAction($id)
    {
        if(!$this->get("session")->get("admin_id")){

            return $this->render('AdminBundle:Auth:login.html.twig');
        }

        $data = $this->getApiData("ApiBundle:Admin/Project:detailProject",array("id"=>$id));

        $data['curr_date'] = date("Y-m-d");
        return $this->render("AdminBundle:Project:projectDetail.html.twig",array("data"=>$data));
    }
}